﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class ReadNotice : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Permission per = new Permission(int.Parse(Session["gid"].ToString()));
        if(per.awaccess==0)
            CGeneral.GoToErrorPage(Response, "custom", "YOU NEED MORE POWER");

        if(Request.QueryString["type"]!=null)
        {
            if(Request.QueryString["type"]=="notice")
            {
                if (Request.QueryString["nid"] != null)
                {
                    int nid = Check.CheckToInt(Request.QueryString["nid"]);
                    if (nid == -1)
                        CGeneral.GoToErrorPage(Response, "custom", "nid ERROR");
                    CNotice cn = new CNotice(nid);
                    if (cn.isExist == 0)
                        CGeneral.GoToErrorPage(Response, "custom", "NO THIS NOTICE");
                    if (int.Parse(Session["uid"].ToString()) != cn.toUid)
                        CGeneral.GoToErrorPage(Response, "custom", "NOT YOUR NOTICE");
                    SaveData.UpdateNotice(cn);
                }

                if (Request.QueryString["goto"] != null)
                {
                    Response.Redirect(Request.QueryString["goto"]);
                }
            }

        }


    }
}